/**
 * \* Created with IntelliJ IDEA.
 * \* User: Administrator
 * \* Date: 2022/1/3
 * \* Time: 11:51
 * \* To change this template use File | Settings | File Templates.
 * \* Description:
 * \
 */
public class TestDemo {

    public String dayOfTheWeek(int day, int month, int year) {
        String []week={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
        int[] monthDays={31,28,31,30,31,30,31,31,30,31,30,31};//1-11月份对应的天数
        int sum=0;
        //计算所给年份与1971年相隔的天数
        for(int i=1971;i<year;i++){
            if(is_leap(i)){
                sum+=366;
            }else {
                sum+=365;
            }
        }
        //计算所给月份在所给年份之前的天数
        for(int i=0;i<month-1;i++){
            if(month>2&&is_leap(i)){
                sum+=1+day;
            }else {
                sum+=day;
            }
        }
        //
        int temp=sum%7;
        return week[(temp+3)%7];
    }

    public boolean is_leap(int year){
        return (year%400==0)||(year%4==0 && year%100!=0);
    }
}

